package ory.yy;

import org.junit.Test;
import redis.clients.jedis.HostAndPort;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisCluster;
import redis.clients.jedis.JedisPoolConfig;

import java.util.HashSet;
import java.util.Set;

public class RedisClusterTest {

    @Test
    public void jedisTest() {
        Jedis jedis = new Jedis("192.168.31.230", 7001);
        Set<String> keys = jedis.keys("*");
        System.out.println(keys);
    }

    @Test
    public void jedisClusterTest() {
        JedisPoolConfig config = new JedisPoolConfig();

        HashSet<HostAndPort> set = new HashSet<HostAndPort>();
        for (int i = 7001; i <= 7008; i++) {
            set.add(new HostAndPort("192.168.31.230", i));
        }
        System.out.println(set);

        JedisCluster cluster = new JedisCluster(set, config);
        System.out.println(cluster.set("k1","v11"));

    }

}
